<?php
	if(isset($_POST['submit'])){
		$table = $_POST['table'];
		$total = $_POST['total'];		
		
		$dbhost = 'localhost';
		$dbuser = 'root';
		$dbpass = 'papamama';
		$dbname = 'Restaurant';
		
		if($table == 0 or $total == 0) {
				echo "Please specify your table number and choose some food";
		}
		else{
			
			$choices = "";
			if(isset($_POST['raumuong'])){
				$choices = $choices.'rau muong - ';			
			}
			
			if(isset($_POST['ocluoc'])){
				$choices.='oc luoc - ';				
			}	
			
			if(isset($_POST['ocbungchuoidau'])){
				$choices.='oc bung chuoi dau - ';				
			}
			
			if(isset($_POST['bunca'])){
				$choices.='bun ca - ';				
			}
			
			$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
			
			//echo $choices;
			
			if ($conn) {
				//insert the record to the database
				mysql_select_db($dbname) or die ('Unable to select database');
				$query = "INSERT INTO payment VALUES ('$table', '$choices','$total','PAYING')";
				mysql_query($query);
				
				echo "The total money is $".$total."<br>";
				echo "Please tap your phone to the card to pay";
			}
		}
	}
	
?>